package com.penfei.springrun.controller;

import com.penfei.springrun.model.UserInfoTestKt;
import com.penfei.springrun.result.CodeMsg;
import com.penfei.springrun.result.ResponseResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestJava {
    @RequestMapping("/getUser")
    @ResponseBody
    public ResponseResult getUser() {
        return ResponseResult.Companion.success(new UserInfoTestKt("张三", 13, "法外狂徒"));
    }

    @RequestMapping("/getUserFail")
    @ResponseBody
    public ResponseResult getUserFail() {
        return ResponseResult.Companion.fail();
    }

    @RequestMapping("/getUserFailWithCustomizeMsg")
    @ResponseBody
    public ResponseResult getUserFailWithCustomizeMsg() {
        return ResponseResult.Companion.fail(CodeMsg.DATA_BASE_CONNECT_ERROR);
    }
}
